/**
 * 
 */
package os.filesystem.file;

import java.io.Serializable;
import java.util.Date;

/**
 * Abstract class defining a file.
 * 
 * @author Raghav Sidhanti
 * @since Mar 6, 2012 10:06:17 AM
 * 
 */
public abstract class File implements Serializable {
	private static final long serialVersionUID = 4929938799680236858L;

	public static final class FileMeta implements Serializable {

		private static final long serialVersionUID = 9070505571924158579L;

		public FileMeta(String creator, String name, String type,
				Date createDate) {
			this.creator = creator;
			this.type = type;
			this.name = name;
			this.absoluteName = "";
			this.createDate = createDate;
		}

		private String creator;
		private String name;
		private String absoluteName;
		private String type;
		private Date createDate;

		public String getAbsoluteName() {
			return absoluteName;
		}

		public String getCreator() {
			return creator;
		}

		public String getName() {
			return name;
		}

		public String getType() {
			return type;
		}

		public Date getCreateDate() {
			return createDate;
		}

		/**
		 * @param absoluteName the absoluteName to set
		 */
		void setAbsoluteName(String absoluteName) {
			this.absoluteName = absoluteName;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof FileMeta) {
				FileMeta fm = (FileMeta) obj;
				return (creator.equals(fm.creator) && name.equals(fm.name)
						&& absoluteName.equals(fm.absoluteName)
						&& type.equals(fm.type) && createDate
							.equals(fm.createDate));
			}

			return false;
		}
	}

	private FileMeta fm;

	/**
	 * Constructor for class.
	 */
	public File(String name, String creator) {
		fm = new FileMeta(creator, name, getType(),
				new Date());
	}

	public FileMeta getMeta() {
		return fm;
	}
	
	public abstract String getType();
}
